home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / cross / avra-0.4_src.lha / avra-0.4 / args.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-28  |  2.1 KB  |  65 lines

  1. /***********************************************************************
  2.  *  args - Argument reading system
  3.  *  Copyright (C) 1997-1999 Jon Anders Haugum
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.  *  Boston, MA 02111-1307, USA.
  19.  *
  20.  *
  21.  *  Author of args can be reached at:
  22.  *     email: jonah@colargol.tihlde.hist.no
  23.  *     Postal address: Jon Anders Haugum
  24.  *                     Øvre Møllenbergsgt 52
  25.  *                     7014 Trondheim
  26.  */
  27.  
  28. enum
  29.     {
  30.     ARGTYPE_BOOLEAN = 0,       /* boolean Value (0 = False) */
  31.     ARGTYPE_STRING,            /* Stringpointer in Data     */
  32.     ARGTYPE_STRING_MULTI,      /* List of strings in Data   */
  33.     ARGTYPE_STRING_MULTISINGLE /* List of strings in Data. requires an option for each elemtent */
  34.     };
  35.  
  36. #define GET_ARG(args,argnum) (args->arg[argnum].data)
  37. #define SET_ARG(args,argnum,value) (args->arg[argnum].data = (void *)value)
  38.  
  39. struct args
  40.     {
  41.     struct arg *arg;
  42.     int count;
  43.     struct data_list *first_data;
  44.     };
  45.  
  46. struct arg
  47.     {
  48.     int type;
  49.     char letter;
  50.     char *longarg;
  51.     void *data;
  52.     };
  53.  
  54. struct data_list
  55.     {
  56.     struct data_list *next;
  57.     void *data;
  58.     };
  59.  
  60. struct args *alloc_args(int arg_count);
  61. int read_args(struct args *args, int argc, char *argv[]);
  62. int add_arg(struct data_list **last_data, char *argv);
  63. void free_args(struct args *args);
  64. void define_arg(struct args *args, int index, int type, char letter, char *longarg, void *def_value);
  65.